Skip to content

fix(cli): require a boolean email_verified claim in GoogleOidcVerifier - #7295

Closed
vishal-bulbule wants to merge 2 commits into
google:mainfrom
vishal-bulbule:fix/oidc-email-verified-bool
Closed

vishal-bulbule wants to merge 2 commits into
google:mainfrom
vishal-bulbule:fix/oidc-email-verified-bool

Conversation

@vishal-bulbule

@vishal-bulbule vishal-bulbule commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Link to Issue or Description of Change

Link to an existing issue:

Problem:
GoogleOidcVerifier checks the email_verified claim with Python truthiness (not claims.get("email_verified")). Any non-empty string, including "false", and any non-zero number counts as verified when the email is on the allowlist. OpenID Connect defines email_verified as a JSON boolean.

Solution:
Require the claim to be exactly True (claims.get("email_verified") is not True rejects everything else). Google-issued ID tokens already carry a boolean, so behaviour for real tokens is unchanged; the change closes the gap for any other claim shape. One line in src/google/adk/cli/trigger_routes.py, plus parametrized unit tests.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

New test test_rejects_non_boolean_email_verified in tests/unittests/cli/test_trigger_routes.py, parametrized over "false", "true" and 1 for both trigger endpoints (Pub/Sub and Eventarc).

New test test_rejects_missing_or_null_email_verified, covering an absent claim and an explicit null on both endpoints (cases from #7309). These already return 403 on main, so they pin that behavior rather than prove the fix.

Against main (tests only, no fix):

pytest tests/unittests/cli/test_trigger_routes.py -k email_verified
6 failed, 4 passed, 71 deselected, 1 warning in 1.14s

With the fix, rebased onto main 044a1ec, whole file:

pytest tests/unittests/cli/test_trigger_routes.py
81 passed, 1 warning in 2.51s

pytest tests/unittests -n auto
16307 passed, 84 skipped, 26 xfailed, 2 xpassed

pre-commit run --files on both files: clean. On the first revision, tox (py310 to py314): py310, py311 and py313 pass the full unit suite (16146, 16155 and 16146 passed). py312 and py314 each report 2 failures in test_import_loading.py::test_entry_point_loads_only_allowlisted_packages[agent|runner] about sitecustomize. Both come from the sitecustomize.py that Homebrew ships inside its python@3.12 and python@3.14 installs, reproduce on unpatched main, and do not occur on uv-managed 3.12.14 and 3.14.7 (92 passed for the import-loading and trigger_routes test files on each).

Manual End-to-End (E2E) Tests:

Script that builds a GoogleOidcVerifier(audience=..., allowed_emails=["allowed@project.iam"]), patches google_id_token.verify_oauth2_token to return a claim set with the given email_verified, and calls the verifier with a bearer header.

On main (9a33588):

  email_verified=True     -> 200 accepted
  email_verified=False    -> 403 Untrusted token principal.
  email_verified='false'  -> 200 accepted
  email_verified='true'   -> 200 accepted
  email_verified=1        -> 200 accepted

With this change:

  email_verified=True     -> 200 accepted
  email_verified=False    -> 403 Untrusted token principal.
  email_verified='false'  -> 403 Untrusted token principal.
  email_verified='true'   -> 403 Untrusted token principal.
  email_verified=1        -> 403 Untrusted token principal.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas. (One-line change; the test docstring explains the rule.)
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

adk-go applies the same boolean requirement in its Google OIDC authenticator (server/authn/googleoidc.go).

The allowlist check in GoogleOidcVerifier tested the email_verified claim
with Python truthiness, so any non-empty string such as "false" counted as
verified when the email was on the allowlist. OpenID Connect defines
email_verified as a JSON boolean, so the check now requires the value to be
exactly True. Google-issued ID tokens already carry a boolean; this closes
the gap for any other claim shape.

Fixes google#7289
@vishal-bulbule
vishal-bulbule force-pushed the fix/oidc-email-verified-bool branch from f190a9e to aaa1a39 Compare September 28, 2026 07:39
copybara-service Bot pushed a commit that referenced this pull request Oct 3, 2026
Merge #7295

`GoogleOidcVerifier` now requires the OIDC `email_verified` claim to be the
boolean `True` rather than any truthy value when `allowed_emails` is set,
rejecting non-boolean truthy values such as `"false"`, `"true"`, or `1` with
HTTP 403.

Fixes #7289

PiperOrigin-RevId: 992637771
@adk-bot

adk-bot commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

Thank you @vishal-bulbule for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit 4434070.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Oct 3, 2026
@adk-bot adk-bot closed this Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged [Status] This PR is merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GoogleOidcVerifier treats string "false" as a verified email claim

2 participants